<div id="view-content">
    <?php if (!empty($this->messages)) { ?>
    <div class="messages">
        <?php foreach ($this->messages as $message) {
        echo $message . '<br>';
    }?>
    </div>
    <?php } ?>
     <table>
         <tr>
             <td>Категория</td>
             <td>Родитель</td>
             <td>Кол-во постов</td>
             <td></td>
             <td></td>
         </tr>
        <?php foreach ($this->categories as $category)  : ?>
             <tr>
                 <td><?php echo $category->title ?></td>

                 <?php if ($category->parent_id) : ?>
                    <td><?php echo $this->parentCategory[$category->parent_id] ?></td>
                 <?php else : ?>
                     <td>Корневая</td>
                 <?php endif; ?>

                 <td></td>
                 <td><a href="<?php echo $this->url(array('module' => 'admin',
                                                          'controller' => 'categories',
                                                          'action' => 'edit-category',
                                                          'id' => $category->id),
                                                          'editCategory');
                     ?>">Edit</td>
                 <?php if ($category->id != 1) : ?>
                 <td><a href="<?php echo $this->url(array('module' => 'admin',
                                                          'controller' => 'categories',
                                                          'action' => 'delete',
                                                          'id' => $category->id),
                                                          'deleteCategory');
                     ?>">Delete</a></td>
                 <?php else : ?>
                 <td>Delete</td>
                 <?php endif; ?>
             </tr>
         <?php endforeach ?>
    </table>
    <div><a href="<?php echo $this->url(array(), 'addCategory', TRUE); ?>">Создать категорию</a></div>
</div>

